package cn.lanqiao.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;

import cn.lanqiao.entity.User;
import cn.lanqiao.util.ReadFile;

public class UserFrm extends JFrame {

	private JPanel contentPane;
	private User user;
	/**
	 * Create the frame.
	 */
	public UserFrm(User user) {
		this.user = user;
		setTitle("用户主页");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 789, 633);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel.setBounds(10, 13, 367, 217);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\userface.jpg"));//加载用户头像
		lblNewLabel.setBounds(0, 0, 204, 217);
		panel.add(lblNewLabel);
		
		JLabel lblId = new JLabel("ID");
		lblId.setBounds(218, 24, 72, 18);
		panel.add(lblId);
		
		JLabel lblNewLabel_1 = new JLabel("new label");
		lblNewLabel_1.setBounds(218, 55, 122, 18);
		lblNewLabel_1.setText(this.user.getUserID());
		panel.add(lblNewLabel_1);
		
		JLabel label = new JLabel("个性签名");
		label.setBounds(218, 86, 72, 18);
		panel.add(label);
		
		JLabel lblNewLabel_2 = new JLabel("new label");
		lblNewLabel_2.setBounds(218, 117, 135, 18);
		lblNewLabel_2.setText(this.user.getSign());
		panel.add(lblNewLabel_2);
		
		JLabel label_1 = new JLabel("最后登录时间");
		label_1.setBounds(218, 148, 97, 18);
		panel.add(label_1);
		
		SimpleDateFormat slf = new SimpleDateFormat("yyyy-MM-dd");
		
		JLabel lblNewLabel_3 = new JLabel("new label");
		lblNewLabel_3.setBounds(218, 179, 104, 18);
		lblNewLabel_3.setText((slf.format(new Date())));
		panel.add(lblNewLabel_3);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setBounds(10, 243, 746, 171);
		contentPane.add(panel_1);
		panel_1.setLayout(null);
		
//		JLabel label_2 = new JLabel("段位");
//		label_2.setBounds(39, 140, 30, 18);
//		panel_1.add(label_2);
		
		JLabel lblNewLabel_4 = new JLabel("New label");
		lblNewLabel_4.setBounds(46, 31, 94, 96);
		lblNewLabel_4.setIcon(new ImageIcon(ReadFile.readFile("src\\cn\\lanqiao\\source\\U_Level\\",this.user.getU_Level())));
		panel_1.add(lblNewLabel_4);
		
		JLabel label_3 = new JLabel("总场次");
		label_3.setBounds(239, 31, 72, 18);
		panel_1.add(label_3);
		
		JLabel label_4 = new JLabel("胜场数");
		label_4.setBounds(388, 31, 72, 18);
		panel_1.add(label_4);
		
		JLabel lblMvp = new JLabel("MVP场数");
		lblMvp.setBounds(527, 31, 72, 18);
		panel_1.add(lblMvp);
		
		JLabel label_5 = new JLabel("战斗力");
		label_5.setBounds(239, 109, 72, 18);
		panel_1.add(label_5);
		
		JLabel label_6 = new JLabel("英雄数");
		label_6.setBounds(388, 109, 72, 18);
		panel_1.add(label_6);
		
		JLabel label_7 = new JLabel("皮肤数");
		label_7.setBounds(527, 109, 72, 18);
		panel_1.add(label_7);
		
		JLabel lblNewLabel_5 = new JLabel("New label");
		lblNewLabel_5.setBounds(226, 62, 72, 18);
		lblNewLabel_5.setText(new Integer(this.user.getTotalNum()).toString());//用户总场次
		panel_1.add(lblNewLabel_5);
		
		JLabel lblNewLabel_6 = new JLabel("New label");
		lblNewLabel_6.setBounds(366, 62, 72, 18);
		lblNewLabel_6.setText(new Float(this.user.getWinNum()).toString());
		panel_1.add(lblNewLabel_6);
		
		JLabel lblNewLabel_7 = new JLabel("New label");
		lblNewLabel_7.setBounds(513, 62, 72, 18);
		lblNewLabel_7.setText(new Integer(this.user.getMVPNum()).toString());
		panel_1.add(lblNewLabel_7);
		
		JLabel lblNewLabel_8 = new JLabel("New label");
		lblNewLabel_8.setBounds(226, 140, 72, 18);
		lblNewLabel_8.setText(new Integer(this.user.getFC()).toString());
		panel_1.add(lblNewLabel_8);
		
		JLabel lblNewLabel_9 = new JLabel("New label");
		lblNewLabel_9.setBounds(366, 140, 72, 18);
		lblNewLabel_9.setText(new Integer(this.user.getHeroNum()).toString());
		panel_1.add(lblNewLabel_9);
		
		JLabel lblNewLabel_10 = new JLabel("New label");
		lblNewLabel_10.setBounds(513, 140, 72, 18);
		lblNewLabel_10.setText(new Integer(this.user.getSkinNum()).toString());
		panel_1.add(lblNewLabel_10);
		
		JLabel lblNewLabel_11 = new JLabel("New label");
		lblNewLabel_11.setBounds(613, 31, 119, 127);
		panel_1.add(lblNewLabel_11);
		
		JLabel lblNewLabel_20 = new JLabel("New label");
		lblNewLabel_20.setBounds(83, 140, 72, 18);
		lblNewLabel_20.setText(this.user.getU_Level());
		panel_1.add(lblNewLabel_20);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_2.setBounds(10, 427, 747, 146);
		contentPane.add(panel_2);
		panel_2.setLayout(null);
		
		JButton btnNewButton = new JButton("历史战绩");
		btnNewButton.setBounds(32, 30, 94, 80);
		panel_2.add(btnNewButton);
		
		JButton button = new JButton("英雄池");
		button.setBounds(176, 30, 94, 80);
		panel_2.add(button);
		
		JButton button_1 = new JButton("好友列表");
		button_1.setBounds(334, 30, 94, 80);
		panel_2.add(button_1);
		
		JButton button_2 = new JButton("常用英雄");
		button_2.setBounds(489, 30, 94, 80);
		panel_2.add(button_2);
		
		JButton button_3 = new JButton("退出程序");//直接退出程序
		button_3.setBounds(639, 30, 94, 80);
		button_3.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option = JOptionPane.showConfirmDialog(null, "确认退出?", "退出提醒", JOptionPane.YES_NO_OPTION);
				if (option == 0) {
					System.exit(0);
				}
				return;
			}
		});
		panel_2.add(button_3);
		
		JPanel panel_3 = new JPanel();
		panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_3.setBounds(391, 13, 366, 217);
		contentPane.add(panel_3);
		panel_3.setLayout(null);
		
	}
}